<!DOCTYPE html>
<html>

<head th:include="cultivateWeb/header :: culHeaderCss">
</head>
<link type="text/css" href="/css/cultivateWeb/style/my.css" rel="stylesheet">
<link type="text/css" href="/css/cultivateWeb/style/news.css" rel="stylesheet">
<link rel="stylesheet" href="/css/cultivateWeb/style/apply.css">
<style>
    .span_1 {
        width: 160px !important;
    }

    .div_3 {
        width: 100%;
    }

    #tishi {
        position: absolute;
        top: 50%;
        left: 40%;
        font-size: 14px;
    }

    .layui-upload-list img {
        width: 100%;
        max-height: 220px;
    }

    .div_3 {
        width: 50%;
    }

    .inps_1 {
        width: 100px;
        height: 50px;
        float: left;
        margin: 20px auto 10px;
    }

    .accessory {
        /* display: flex; */
        width: 300px;
        /*height:500px*/
    }

    .synopsis {
        position: absolute;
        bottom: -10%;
        right: 27%
    }
</style>

<body>
    <!-- 顶部导航 -->
    <header th:include="cultivateWeb/header :: header"></header>
    <div style="clear: both"></div>
    <div style="background-color: #f7f7f7; ">

        <hr style="margin: auto auto 40px auto  ; width: 1200px" />
        <section id="info" style="margin:30px;">
            <div style="width: 1150px;margin:0 auto;">
                <div class="layui-container" style="height: 40px;">
                    <p style="font-size: 16px;">机构信息&nbsp;&nbsp;&nbsp;<span
                            style="font-size:14px;color: #D52525;">(红色星号标记的内容为必填)</span></p>
                </div>
                <hr style="margin: 0 auto ;" />
                <div style="clear: both"></div>
                <form id="formId">
                    <div style="text-align: center">
                        <div class="div_3">
                            <label class="span_1">法人代表<span style="color: #D52525">*</span>：</label>
                            <input type="text" id="legalPErson" value="" name="legalPErson"
                                class="form-control inp_1" />
                        </div>
                        <div class="div_3">
                            <label class="span_1">法人联系电话<span style="color: #D52525">*</span>：</label>
                            <input type="text" name="legalPErsonPhone" value="" id="legalPErsonPhone" placeholder=""
                                class="form-control inp_1" />
                        </div>

                        <div class="div_3">
                            <label class="span_1">负责人<span style="color: #D52525">*</span>：</label>
                            <input type="text" name="principal" value="" id="principal" placeholder=""
                                class="form-control inp_1" />
                        </div>
                        <div class="div_3">
                            <label class="span_1">负责人联系电话<span style="color: #D52525">*</span>：</label>
                            <input type="text" name="principalPhone" value="" id="principalPhone" placeholder=""
                                class="form-control inp_1" />
                        </div>
                        <div class="div_3">
                            <label class="span_1">机构所在地<span style="color: #D52525">*</span>：</label>
                            <input type="text" name="address" value="" id="address" placeholder=""
                                class="form-control inp_1" />
                        </div>
                        <div class="div_3">
                            <label class="span_1">机构网址：</label>
                            <input type="text" name="url" value="" id="url" placeholder="" class="form-control inp_1" />
                        </div>
                        <div class="div_3">
                            <label class="span_1">联系人邮箱：</label>
                            <input type="text" name="mailbox" value="" id="mailbox" placeholder=""
                                class="form-control inp_1" />
                        </div>
                        <div class="div_3">
                            <label class="span_1">机构类型<span style="color: #D52525">*</span>：</label>
                            <input type="hidden" value="" id="nature" placeholder="" class="form-control inp_1" />
                            <select id="unitNature" name="unitNature" class="form-control inp_1">
                                <option value="">请选择机构类型</option>
                                <option value="企业">企业</option>
                                <option value="机关">机关</option>
                                <option value="事业单位">事业单位</option>
                                <option value="社会团体">社会团体</option>
                                <option value="学校">学校</option>
                                <option value="有限责任公司">有限责任公司</option>
                                <option value="其它组织机构">其它组织机构</option>
                            </select>
                        </div>
                        <div class="div_3">
                            <label class="span_1">所属行业<span style="color: #D52525">*</span>：</label>
                            <input type="hidden" value="" id="industrys" placeholder="" class="form-control inp_1" />
                            <select id="industry" name="industry" class="form-control inp_1">
                                <option value="">请选择所属行业</option>
                                <option value="教育">教育</option>
                                <option value="卫生、社会保障和社会服务业">卫生、社会保障和社会服务业</option>
                                <option value="文化、体育、娱乐业">文化、体育、娱乐业</option>
                                <option value="商务服务业">商务服务业</option>
                                <option value="软件和信息技术服务业">软件和信息技术服务业</option>
                                <option value="综合">综合</option>
                                <option value="其它">其它</option>
                            </select>
                        </div>
                        <div class="div_3 company">
                            <label class="span_1">统一社会信用代码<span style="color: #D52525">*</span>：</label>
                            <input type="text" id="orgCode" value="" placeholder="或组织机构代码" name="orgCode"
                                class="form-control inp_1" />
                            <div style="clear: none"></div>
                        </div>
                        <div class="div_3">
                            <label class="span_1">注册资金（万）<span style="color: #D52525">*</span>：</label>
                            <input type="text" id="registerMoney" value="" name="registerMoney" placeholder=""
                                class="form-control inp_1" />
                        </div>

                        <div class="div_3">
                            <label class="span_1">员工人数：</label>
                            <input type="hidden" value="" id="staffSizes" placeholder="" class="form-control inp_1" />
                            <select id="staffSize" name="staffSize" class="form-control inp_1">
                                <option value="">请选择员工人数</option>
                                <option value="0-20人">0-20人</option>
                                <option value="20-99人">20-99人</option>
                                <option value="100-499人">100-499人</option>
                                <option value="500-999人">500-999人</option>
                                <option value="1000人以上">1000人以上</option>
                            </select>
                        </div>
                        <div class="div_3 company">
                            <label class="span_1">成立日期<span style="color: #D52525">*</span>：</label>
                            <input id="setDate" name="setDate" class="form-control inp_1" type="text" value=""
                                placeholder="请选择成立日期">
                        </div>
                        <div class="div_3 company">
                            <label class="span_1">机构LOGO:<span style="color: #D52525">*</span>:</label>
                            <div style="display: flex;width:150px">
                                <div class="layui-upload-list">
                                    <img id="tests" src="">
                                    <input type="text" value="" style="opacity:0;width: 1px;" id="logo"
                                        name="orgPhoto" />
                                </div>
                                <!-- <button type="button" class="layui-btn" id="test2" style="margin:20px">上传</button> -->
                                <button type="button" class="btn inps_1" id="test2"><i
                                        class="fa fa-cloud"></i>上传</button>
                            </div>
                        </div>
                        <!-- <div class="div_3 company">
                            <div class="upload_btn">
                                <label class="span_1">法人身份证正面照<span style="color: #D52525">*</span>:</label>
                                <button type="button" class="btn inps_1" id="test3"><i
                                        class="fa fa-cloud"></i>上传</button>
                            </div>
                            <div class="accessory">
                                <div class="layui-upload-list" style="width: 100%;height: 250px;">
                                    <img class="layui-upload-img" id="front" src="">
                                    <input type="text" value="" style="opacity:0;width: 1px;" id="idCardFront"
                                        name="idCardFront" />
                                </div>

                            </div>
                        </div>
                        <div class="div_3 company">
                            <div class="upload_btn">
                                <label class="span_1">法人身份证反面照<span style="color: #D52525">*</span>:</label>
                                <button type="button" class="btn inps_1" id="test5"><i
                                        class="fa fa-cloud"></i>上传</button>
                            </div>
                            <div class="accessory">
                                <div class="layui-upload-list" style="width: 100%;height: 250px;">
                                    <img class="layui-upload-img" id="verso" src="">
                                    <input type="text" value="" style="opacity:0;width: 1px;" id="idCardVerso"
                                        name="idCardVerso" />
                                </div>
                            </div>
                        </div> -->

                        <div class="div_3 company">
                            <div class="upload_btn">
                                <label class="span_1">营业执照:</label>
                                <button type="button" class="btn inps_1" id="test1"><i
                                        class="fa fa-cloud"></i>上传</button>
                            </div>
                            <div class="accessory">
                                <div class="layui-upload-list" style="width: 100%;height: 250px;">
                                    <img class="layui-upload-img" id="test" src="">
                                    <input type="text" value="" style="opacity:0;width: 1px;" id="img"
                                        name="enclosure" />
                                </div>

                            </div>
                        </div>
                        <div class="div_3 company">
                            <div class="upload_btn">
                                <label class="span_1">授权函:</label>
                                <button type="button" class="btn inps_1" style="width: 130px;" id="test4"><i
                                        class="fa fa-cloud"></i>请盖章后上传</button>
                            </div>
                            <div class="accessory">
                                <div class="layui-upload-list" style="width: 100%;height: 250px;">
                                    <img class="layui-upload-img" id="authorization" src="">
                                    <input type="text" value="" style="opacity:0;width: 1px;" id="authorizations"
                                        name="authorization" />
                                </div>

                            </div>
                        </div>
                        <div class="div_3 company">
                            <div class="upload_btn">
                                <label class="span_1">授权函模板下载:</label>
                                <label
                                    style="height: 50px;float: left;margin: 20px 10px auto auto;font-size: 16px;line-height: 50px;">
                                    <a target="_blank"
                                        href="https://jinzhiweiye.oss-cn-hangzhou.aliyuncs.com/%E6%8B%9B%E8%81%98%E8%B4%9F%E8%B4%A3%E4%BA%BA%E6%8E%88%E6%9D%83%E4%B9%A6.doc"
                                        id="cnBook" style="color: blue" download>授权函附件</a>
                                </label>
                            </div>

                        </div>
                        <div class="div_3 company">
                            <div class="upload_btn">
                                <label class="span_1">授权函示例下载:</label>
                                <label
                                    style="height: 50px;float: left;margin: 20px 10px auto auto;font-size: 16px;line-height: 50px;">
                                    <a target="_blank" href="https://jinzhiweiye.oss-cn-hangzhou.aliyuncs.com/06076.png"
                                        id="cnBooks" style="color: blue" download>授权函示例</a>
                                </label>
                            </div>

                        </div>
                        <div class="div_3" style="width: 100%;position: relative;margin-bottom: 20px;">
                            <label class="span_1">机构简介：</label>
                            <textarea style="width:700px;height:200px;" onkeyup="checkLen(this)"
                                placeholder="请输入机构简介(200字以内)" type="text" id="introduce" name="introduce"
                                class="form-control inp_1"></textarea>
                            <div class="synopsis">您还可以输入 <span id="count">200</span> 个文字</div>
                        </div>
                        <!-- <div class="div_3" style="width: 100%;position: relative;margin-bottom: 20px;">
                            <label class="span_1">产品简介：</label>
                            <textarea style="width:700px;height:200px;" onkeyup="checkLens(this)"
                                placeholder="请输入产品简介(200字以内)" type="text" id="cpsynopsis" name="cpsynopsis"
                                class="form-control inp_1"></textarea>
                            <div class="synopsis">您还可以输入 <span id="counts">200</span> 个文字</div>
                        </div> -->
                        <div class="div_3" style="display: flex;width: 300px;margin: 20px 20px 0;font-size: 16px;">
                            <label>&nbsp;<input id="radio" type="checkbox"></label>&nbsp;&nbsp;
                            <label>请在注册前仔细阅读并同意<a target="_blank" style="color: blue" href="">用户协议</a></label>
                        </div>
                        <div class="div_3">
                            <button class="form-control but_1" id="send" type="button" onclick="subMit()">提交</button>
                        </div>
                    </div>
                    <input type="hidden" id="id" name="id" th:value="${id}">
                    <input type="hidden" id="name" name="name" th:value="${name}">
                    <input type="hidden" id="mobile" name="mobile" th:value="${mobile}">
                    <input type="hidden" id="enId" name="enId" th:value="${enId}">
                </form>
            </div>

            <div style="clear: both"></div>
        </section>
        <!-- 分页 -->
    </div>
    <!-- footer ------------------------------------------------------- -->
    <div class="footer" th:include="cultivateWeb/header :: footer"></div>
    <script src="/js/plugins/layer/layer.min.js" th:src="@{/js/plugins/layer/layer.min.js}"></script>
    <script src="/js/plugins/validate/jquery.validate.extend.js"></script>
    <script src="/js/plugins/validate/jquery.validate.min.js"></script>
    <script src="/js/jquery.citys.js"></script>
    <script src="/js/layui/layui.js"></script>
</body>

<script>
    $(document).ready(function () {
        layui.use(['laydate', 'upload'], function () {
            var laydate = layui.laydate;
            var upload = layui.upload;
            laydate.render({
                elem: '#setDate'
            });
            laydate.render({
                elem: '#startDate'
            });
            laydate.render({
                elem: '#endDate'
            });
            upload.render({
                elem: '#test1',
                url: '/jzApi/utils/fileImprot',
                done: function (r) {
                    $("#img").val(r.data);
                    $("#test").attr("src", r.data);
                },
                error: function (r) {
                    layer.msg(r.msg);
                }
            });
            upload.render({
                elem: '#test2',
                size: 300,
                url: '/jzApi/utils/fileImprot',
                done: function (r) {
                    $("#logo").val(r.data);
                    $("#tests").attr("src", r.data);
                },
                error: function (r) {
                    layer.msg(r.msg);
                }
            });
            upload.render({
                elem: '#test4',
                url: '/jzApi/utils/fileImprot',
                done: function (r) {
                    $("#authorizations").val(r.data);
                    $("#authorization").attr("src", r.data);
                },
                error: function (r) {
                    layer.msg(r.msg);
                }
            });
            upload.render({
                elem: '#test3',
                url: '/jzApi/utils/fileImprot',
                done: function (r) {
                    $("#idCardFront").val(r.data);
                    $("#front").attr("src", r.data);
                },
                error: function (r) {
                    layer.msg(r.msg);
                }
            });
            upload.render({
                elem: '#test5',
                url: '/jzApi/utils/fileImprot',
                done: function (r) {
                    $("#idCardVerso").val(r.data);
                    $("#verso").attr("src", r.data);
                },
                error: function (r) {
                    layer.msg(r.msg);
                }
            });
        });
    });
    $('#legalPErsonPhone').blur(function () {
        var mobile = $("#legalPErsonPhone").val();
        if (!(/^1[3|4|5|6|7|8|9][0-9]\d{8}$/.test(mobile))) {
            layer.msg('手机号码填写错误，请填写正确的手机格式');
            return false
        }
    });
    $('#principalPhone').blur(function () {
        var mobiles = $("#principalPhone").val();
        if (!(/^1[3|4|5|6|7|8|9][0-9]\d{8}$/.test(mobiles))) {
            layer.msg('手机号码填写错误，请填写正确的手机格式');
            return false
        }
    });
    $('#mailbox').blur(function () {
        var mailbox = $("#mailbox").val();
        if (!(/^\w+((-\w+)|(\.\w+))*@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(mailbox))) {
            layer.msg('邮箱格式不正确，请重新输入');
            return false
        }
    });
    function checkLen(obj) {
        var maxChars = 200;//最多字符数
        if (obj.value.length > maxChars)
            obj.value = obj.value.substring(0, maxChars);
        var curr = maxChars - obj.value.length;
        document.getElementById("count").innerHTML = curr.toString();
    };
    // function checkLens(obj) {
    //     var maxChars = 200;
    //     if (obj.value.length > maxChars)
    //         obj.value = obj.value.substring(0, maxChars);
    //     var curr = maxChars - obj.value.length;
    //     document.getElementById("counts").innerHTML = curr.toString();
    // };
    function subMit() {
        var legalPErson = $('#legalPErson').val();
        var legalPErsonPhone = $("#legalPErsonPhone").val();
        var principal = $('#principal').val();
        var principalPhone = $('#principalPhone').val();
        var address = $('#address').val();
        var url = $('#url').val();
        var mailbox = $("#mailbox").val();
        var nature = $('#unitNature').val();
        var industry = $('#industry').val();
        var registerMoney = $('#registerMoney').val();
        var staffSize = $('#staffSize').val();
        var orgCode = $('#orgCode').val();
        var setDate = $('#setDate').val();
        var startDate = $('#startDate').val();
        var finishDate = $('#endDate').val();
        var orgPhoto = $('#logo').val();
        var enclosure = $('#img').val();
        var authorization = $('#authorizations').val();
        var idCardfront = $('#idCardFront').val();
        var idCardverso = $('#idCardVerso').val()
        if (legalPErson == '') {
            layer.msg('请输入法人姓名');
            return false
        }
        if (legalPErsonPhone == '') {
            layer.msg('请输入法人联系电话');
            return false
        }
        if (principal == '') {
            layer.msg('请输入负责人姓名');
            return false
        }
        if (principalPhone == '') {
            layer.msg('请输入负责人联系电话');
            return false
        }
        if (address == '') {
            layer.msg('请选择机构所在地');
            return false
        }
        // if (url == '') {
        //     layer.msg('请选择机构网址');
        //     return false
        // }
        // if (mailbox == '') {
        //     layer.msg('请输入联系人邮箱');
        //     return false
        // }
        if (nature == '') {
            layer.msg('请输入机构性质');
            return false
        }
        if (industry == '') {
            layer.msg('请输入所属行业');
            return false
        }
        if (orgCode == '') {
            layer.msg('请输入统一社会信用代码');
            return false
        }
        if (registerMoney == '') {
            layer.msg('请输入注册资金');
            return false
        }
        // if (staffSize == '') {
        //     layer.msg('请选择员工人数');
        //     return false
        // }
        if (setDate == '') {
            layer.msg('请选择机构成立日期');
            return false
        }
        if (orgPhoto == '') {
            layer.msg('请上传机构logo');
            return false
        }
        // if (enclosure == '') {
        //     layer.msg('请上传营业执照');
        //     return false
        // }
        // if (idCardfront == '') {
        //     layer.msg('请上传法人身份证正面照');
        //     return false
        // }
        // if (idCardverso == '') {
        //     layer.msg('请上传法人身份证反面照');
        //     return false
        // }
        // if (principal != legalPErson) {
        //     if (authorization == '' || authorization == null) {
        //         layer.msg('请上传授权函');
        //         layer.msg('非机构法人请上传授权函');
        //         return false
        //     }
        // }

        if (!$('#radio').prop("checked")) {
            layer.msg("请勾选已阅读注册须知");
            return false
        }
        $.ajax({
            url: '/enterprise/enterpriseUserAdd',
            type: 'GET',
            data: $('#formId').serialize(),
            success: function (res) {
                if (res.code == 0) {
                    layer.msg('注册成功！', { icon: 1 });
                    // location.href = 'http://www.jz1x.com/login?username'+userName+'&password='+passWord
                    var enId = $('#enId').val();
                    $.ajax({
                        url: '/enterprise/enLogin',
                        type: 'POST',
                        data: { enId: enId },
                        success: function (r) {
                            if (r.code == 0) {
                                parent.location.href = '/index';
                            } else {
                            location.href = '/login';
                               
                            }
                        }
                    })
                } else {
                    layer.msg(res.msg)
                }

            }
        })
    }

</script>

</html>